<?php
/**
 * Static class which arranges the database connection and dissconnection
 * 
 * @author Denis
 *
 */
class DatabaseConnection {

	const servername = 'manuras.com';
	const username = 'deb40358_wvdt';
	const password = 'winkel';
	const database = 'deb40358_wvdt';
	private static $connection;
	private static $database_selected;

	public function __construct(){
		
	}

	/**
	 * Makes connection with the database
	 */
	public static function connect(){
		self::$connection = mysql_connect(self::servername, self::username, self::password);
		if(!self::$connection){
			die('Could not connect ' . mysql_error());
		}
		if(!(self::$database_selected = mysql_select_db(self::database))){
			die('Could not select db' . mysql_error());
		}
	}

	/**
	 * Returns the connection
	 */
	public static function getConnection(){
		return self::$connection;
	}
	
	/**
	 * Returns the database connection
	 */
	public static function getDatabaseConnected(){
		return self::$database_selected;
	}
	
	/**
	 * Closes the connection
	 */
	public static function disconnect(){
		if(!mysql_close(self::getConnection())){
			die('Could not dissconnect ' . mysql_error());
		}
		self::$connection = null;
	}
}